<template>
  <view style="padding-bottom: 200rpx;">
    <u-navbar
      v-if="!$isWeixin()"
      :title="IsNewStore == 1 ? '添加新门店' : '新增门店'"
      :background="{ backgroundColor: '#ffffff' }"
      :titleBold="true"
      :is-fixed="true"
    ></u-navbar>

    <u-tabs active-color="#FF7A23" :list="list" :current="current" @change="change"></u-tabs>

    <view class="" v-show="current == 0">
      <u-cell-item
        :arrow="false"
        :border-bottom="false"
        title="一级经销商名称"
        :value="First_Dealer_BaseInfo.Name"
      ></u-cell-item>
      <u-cell-item
        v-if="Level == 2"
        :arrow="false"
        title="二级经销商名称"
        :value="Double_Dealer_BaseInfo.Name"
      ></u-cell-item>

      <u-cell-item :arrow="false" title="门店属性" :border-bottom="false">
        <u-radio-group v-model="form.Door_Dealer_OtherInfo.OldDoor">
          <u-radio name="1">门店新增</u-radio>
          <u-radio name="2">老店新开</u-radio>
        </u-radio-group>
      </u-cell-item>

      <block v-if="Level == 1 && IsNewStore == 1">
        <basic-information-form
          :loadCity="loadCity"
          ref="basicForm2"
          :showAccount="false"
          :level="2"
          :metadata="DataBaseInfo"
          :showApplyReason="true"
          :showSalesInfo="false"
          :showCCType="false"
          :showChannelType="Level == 1"
          :showBrand="true"
        ></basic-information-form>
      </block>

      <u-gap bg-color="#f5f5f5" :height="30"></u-gap>

      <basic-information-form
        :loadCity="loadCity"
        ref="basicForm"
        :showAccount="false"
        :level="3"
        :metadata="DataBaseInfo"
        :showApplyReason="false"
        :showSalesInfo="false"
      ></basic-information-form>

      <block>
        <u-cell-item title="人员数量" :arrow="false" style="" :border-bottom="false"></u-cell-item>

        <u-cell-item title="" :arrow="false">
          <u-button @tap="addPersonCount" type="warning" size="mini">添加</u-button>

          <view class="u-flex u-text-right" v-for="(item, index) in form.DealerPeopleNumList" :key="index">
            <u-input v-model="item.Title" placeholder="请输入标题" :border="true" :height="50"></u-input>
            <text class="u-m-20">:</text>
            <u-input v-model="item.Num" type="number" placeholder="数量" :border="true" :height="50"></u-input>
            <u-button @tap="removePersonCount(index)" style="margin-left: 20rpx;" type="error" size="mini">
              删除
            </u-button>
          </view>
        </u-cell-item>
      </block>
    </view>

    <view class="" v-show="current == 1" style="">
      <u-cell-group style="background-color: #eceaef;">
        <!-- <u-cell-item required :arrow="false" title="属性">
					<u-radio-group v-model="form.Door_Dealer_OtherInfo.DealerType">
						<view class="grid-2">
							<u-radio :label-size="26" v-for="(item, index) in DataBaseInfo.DealerType_BaseList" :key="index" :name="item.Key">{{ item.Value }}</u-radio>
						</view>
					</u-radio-group>
				</u-cell-item> -->

        <u-cell-item required :arrow="false" title="经营品类">
          <u-checkbox-group @change="onStoreBusinessCategoryChange">
            <view class="grid-2">
              <u-checkbox
                :label-size="26"
                v-model="item.checked"
                v-for="(item, index) in DataBaseInfo.StoreBusinessCategory_BaseList"
                :name="item.Key"
                :key="index"
              >
                {{ item.Value }}
              </u-checkbox>
            </view>
          </u-checkbox-group>
        </u-cell-item>

        <u-cell-item required :arrow="false" title="竞品品牌">
          <block>
            <view class="u-text-left u-p-l-20">BDR品牌数: {{ count_A }}</view>
            <u-checkbox-group @change="onStoreCompetingGoodsBrandAChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  v-for="(item, index) in DataBaseInfo.StoreCompetingGoodsBrandA_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
            <u-line></u-line>
          </block>

          <block>
            <view class="u-text-left u-p-l-20">进口品牌数: {{ count_B }}</view>
            <u-checkbox-group @change="onStoreCompetingGoodsBrandBChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  v-for="(item, index) in DataBaseInfo.StoreCompetingGoodsBrandB_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
            <u-line></u-line>
          </block>

          <block>
            <view class="u-text-left u-p-l-20">国产品牌数: {{ count_C }}</view>
            <u-checkbox-group @change="onStoreCompetingGoodsBrandCChange">
              <view class="grid-2">
                <u-checkbox
                  :label-size="26"
                  v-model="item.checked"
                  v-for="(item, index) in DataBaseInfo.StoreCompetingGoodsBrandC_BaseList"
                  :key="index"
                  :name="item.Key"
                >
                  {{ item.Value }}
                </u-checkbox>
              </view>
            </u-checkbox-group>
          </block>
        </u-cell-item>

        <block>
          <u-cell-item title="竞品出样情况" :arrow="false" :border-bottom="false">
            <u-radio-group v-model="form.Door_Dealer_OtherInfo.Sampling">
              <u-radio name="1">是</u-radio>
              <u-radio name="2">否</u-radio>
            </u-radio-group>
          </u-cell-item>

          <u-cell-item title="" style="padding: 0;" :arrow="false">
            <view class="u-m-20" v-if="form.Door_Dealer_OtherInfo.Sampling == 1">
              <view class="samling-item" v-for="(item, index) in form.DealerSamplingSellList" :key="index">
                <u-button @tap="removeSampling(index)" type="error" size="mini" class="u-m-b-10">删除</u-button>
                <u-input v-model="item.BrandName" :border="true"></u-input>
                <u-input v-model="item.ProductModel" class="u-m-t-10" :border="true"></u-input>
                <u-input
                  class="u-m-t-10"
                  type="number"
                  :border="true"
                  placeholder="数量"
                  v-model="item.Number"
                ></u-input>

                <u-gap bg-color="#f5f5f5" class="u-m-t-10 u-m-b-10" :height="10"></u-gap>
              </view>

              <view class="u-text-right u-m-t-10 u-m-b-10 u-p-r-40">
                <u-button @tap="addSampling" type="warning" size="mini">添加竞品样机</u-button>
              </view>
            </view>
          </u-cell-item>
        </block>

        <block>
          <u-cell-item title="样机情况" :arrow="false" :border-bottom="false"></u-cell-item>
          <u-cell-item style="padding: 0;" :arrow="false">
            <view class="u-m-20">
              <view class="samling-item" v-for="(item, index) in form.DealerVisitSellList" :key="index">
                <u-button @tap="removeVisitSell(index)" type="error" size="mini" class="u-m-b-10">删除</u-button>
                <u-input
                  type="select"
                  :value="item.BrandName"
                  :border="true"
                  @tap="(showVisitSellPicker = true), (currentVisitSellIndex = index)"
                  :selectOpen="showVisitSellPicker"
                ></u-input>
                <u-input
                  :value="item.productName"
                  class="u-m-t-10"
                  type="select"
                  @tap="(showVisitSellProductPicker = true), (currentVisitSellIndex = index)"
                  :selectOpen="showVisitSellProductPicker"
                  :border="true"
                ></u-input>
                <u-input
                  class="u-m-t-10"
                  type="number"
                  :border="true"
                  placeholder="数量"
                  v-model="item.Number"
                ></u-input>

                <u-gap bg-color="#f5f5f5" class="u-m-t-10 u-m-b-10" :height="10"></u-gap>
              </view>

              <view class="u-text-right u-m-t-10 u-m-b-10 u-p-r-40">
                <u-button @tap="addVisitSell" type="warning" size="mini">添加BDR样机情况</u-button>
              </view>
            </view>
          </u-cell-item>
        </block>
      </u-cell-group>
    </view>

    <!-- 销售信息 -->
    <view class="" v-show="current == 2">
      <u-cell-item :arrow="false" title="上一年对应代理商供暖销售额">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_DealerHeatingSales"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">万元</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年对应代理商空凋销售额">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_DealerAirConditionerSales"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">万元</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年对应代理商净水销售额">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_DealerPurifiedWaterSales"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">万元</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年门店供暖销售额">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_StoreHeatingSales"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">万元</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年门店空凋销售额">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_StoreAirConditionerSales"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">万元</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年门店净水销售额">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">万元</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年销售BDR供暖产品台数">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">台</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年销售BDR净水产品台数">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">台</text>
          </view>
        </view>
      </u-cell-item>

      <u-cell-item :arrow="false" title="上一年销售BDR热泵产品台数">
        <view class="u-flex-col u-col-bottom">
          <view class="u-flex">
            <u-input
              v-model="form.Door_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum"
              type="number"
              inputAlign="right"
              placeholder="请输入"
            ></u-input>
            <text class="unit u-m-l-32">台</text>
          </view>
        </view>
      </u-cell-item>
    </view>

    <!-- 门店周边情况 -->
    <view class="" v-show="current == 3">
      <u-cell-group>
        <u-cell-item :arrow="false" title="新店所属市级区域供暖市场容量">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.AS_HeatingMarketCapacity"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item :arrow="false" title="新店所属市级区域热泵市场容量">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.AS_HeatPumpMarketCapacity"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item :arrow="false" title="周边1公里竞品门店数">
          <u-input
            v-model="form.Door_Dealer_OtherInfo.AS_CompetingStoresNum"
            type="number"
            inputAlign="right"
            placeholder="请输入"
          ></u-input>
        </u-cell-item>

        <u-cell-item :arrow="false" title="周边1公里竞品品牌">
          <u-input
            v-model="form.Door_Dealer_OtherInfo.AS_CompetingBrand"
            type="number"
            inputAlign="right"
            placeholder="请输入"
          ></u-input>
        </u-cell-item>

        <u-cell-item :arrow="false" title="周边1公里竞品做最好的品牌">
          <u-input
            v-model="form.Door_Dealer_OtherInfo.AS_BestCompetingBrand"
            type="number"
            inputAlign="right"
            placeholder="请输入"
          ></u-input>
        </u-cell-item>

        <u-cell-item :arrow="false" title="周边1公里竞品做最好品牌的年供暖销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item :arrow="false" title="周边1公里竞品做最好品牌的年热泵销售额">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">万元</text>
            </view>
          </view>
        </u-cell-item>

        <block>
          <u-cell-item title="开店原因" :arrow="false" style="padding-bottom: 0;" :border-bottom="false"></u-cell-item>
          <u-cell-item :arrow="false" style="padding: 0rpx 40rpx;">
            <u-input type="textarea" v-model="form.Door_Dealer_OtherInfo.AS_ReasonOpeningStore"></u-input>
          </u-cell-item>
        </block>

        <u-cell-item :arrow="false" title="新店预估年壁挂炉台数">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.NY_Estimate_FireplaceNum"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item :arrow="false" title="新店预估年净水台数">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.NY_Estimate_CleanWaterNum"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item :arrow="false" title="新店预估年热泵台数">
          <view class="u-flex-col u-col-bottom">
            <view class="u-flex">
              <u-input
                v-model="form.Door_Dealer_OtherInfo.NY_Estimate_HeatPumpNum"
                type="number"
                inputAlign="right"
                placeholder="请输入"
              ></u-input>
              <text class="unit u-m-l-32">台</text>
            </view>
          </view>
        </u-cell-item>

        <u-cell-item :arrow="false" title="补贴方式">
          <u-radio-group v-model="form.Door_Dealer_OtherInfo.SubsidyMethod">
            <u-radio name="1">现金</u-radio>
            <u-radio name="2">市场返利</u-radio>
          </u-radio-group>
        </u-cell-item>

        <u-cell-item :arrow="false" title="申请类型">
          <u-radio-group v-model="form.Door_Dealer_OtherInfo.StoreApplyType">
            <u-radio name="1">焕新</u-radio>
            <u-radio name="2">新建</u-radio>
          </u-radio-group>
        </u-cell-item>
      </u-cell-group>
    </view>

    <!-- 门店展陈信息 -->
    <!-- <view class="" v-show="current == 4">
			<u-cell-group>
				<u-cell-item title="门店等级" :arrow="false">
					<u-radio-group v-model="form.Door_Dealer_OtherInfo.FlagshipState">
						<view class="grid-2">
							<u-radio v-for="(item, index) in DealerGrade_VisitList" :key="index" :name="item.Key">{{ item.Value }}</u-radio>
						</view>
					</u-radio-group>
				</u-cell-item>

				<block>
					<u-cell-item title="走访模块" :arrow="false" :border-bottom="false"></u-cell-item>
					<u-cell-item title="" :arrow="false" style="padding: 0 20rpx">
						<u-checkbox-group>
							<view class="visit-grid">
								<view class="visit-item" v-for="(item, index) in DealerVisitCategorylistModel" :key="index">
									<view class="title u-line-1 u-m-b-10">
										<u-checkbox v-model="item.checked" :name="item.Id">
											<text>{{ item.Name }}</text>
											<text style="color: red;" v-if="item.Id == 1">*</text>
										</u-checkbox>
									</view>
									<u-image @tap="selectFile(index)" :width="180" :height="180" :src="$getImageUrl(item.Pic)"></u-image>
								</view>
							</view>
						</u-checkbox-group>
					</u-cell-item>
				</block>
			</u-cell-group>
		</view>
 -->
    <!-- 门店开户照片 -->
    <view class="" v-show="current == 4">
      <new-store-photo v-model="form.InitialStorePhoto" :showAdd="true"></new-store-photo>
    </view>

    <view class="" v-show="current == 5">
      <u-cell-group>
        <u-cell-item :arrow="false" title="申请类型" value="新增"></u-cell-item>
        <u-cell-item :arrow="false" title="申请原因">
          <u-radio-group v-model="form.Door_ApplyForReasonId">
            <view class="grid-2">
              <u-radio v-for="(item, index) in DataBaseInfo.DealerApplyFor_BaseList" :name="item.Key" :key="index">
                {{ item.Value }}
              </u-radio>
            </view>
          </u-radio-group>
        </u-cell-item>
        <u-cell-item v-if="form.Door_ApplyForReasonId == 3" :arrow="false" title="物料需求">
          <u-checkbox-group @change="onRequirementsChange">
            <view class="grid-2">
              <u-checkbox
                v-model="item.checked"
                v-for="(item, index) in DataBaseInfo.DealerMaterialRequirements_BaseList"
                :name="item.Key"
                :key="index"
              >
                {{ item.Value }}
              </u-checkbox>
            </view>
          </u-checkbox-group>
        </u-cell-item>
        <u-cell-item v-if="form.Door_ApplyForReasonId == 4" :arrow="false" title="费用需求">
          <u-checkbox-group @change="onRequirementsChange">
            <view class="grid-2">
              <u-checkbox
                v-model="item.checked"
                v-for="(item, index) in DataBaseInfo.DealerMoneyRequirements_BaseList"
                :name="item.Key"
                :key="index"
              >
                {{ item.Value }}
              </u-checkbox>
            </view>
          </u-checkbox-group>
        </u-cell-item>

        <u-cell-item title="审核流品牌" :arrow="false" :border-bottom="false" required>
          <u-radio-group v-model="form.Aub_Brand">
            <view class="grid-2">
              <u-radio :label-size="26" :name="5">八喜</u-radio>
              <u-radio :label-size="26" :name="6">夏贝</u-radio>
              <u-radio :label-size="26" :name="7">德地氏</u-radio>
              <u-radio :label-size="26" :name="8">伯爵</u-radio>
              <u-radio :label-size="26" :name="0">无</u-radio>
            </view>
          </u-radio-group>
        </u-cell-item>
        <u-cell-item :arrow="false" style="padding: 0 30rpx;">
          <view style="color: red; text-align: left;">
            请选择审核流品牌，此选项是根据所选品牌指定对应审核流，选择“无”代表无需根据品牌判断使用指定审核流，在所选品牌查找不到审核流信息时，会查询所有审核流中的第一条做为审核流程
          </view>
        </u-cell-item>

        <u-cell-item v-if="form.Door_ApplyForReasonId == 5" :arrow="false" title="其他备注">
          <u-input
            v-model="form.Door_OtherNote"
            :autoHeight="true"
            type="textarea"
            inputAlign="right"
            placeholder="其他备注"
          ></u-input>
        </u-cell-item>
      </u-cell-group>
    </view>

    <view class="btn-group-fixed u-flex">
      <u-button
        type=""
        @click="
          $u.route({
            type: 'back'
          })
        "
      >
        返回列表
      </u-button>
      <u-button :disabled="btnDisabled" type="warning" @click="onSubmit">提交申请</u-button>
    </view>

    <u-upload
      style="display: none;"
      class="upload-item"
      ref="upload"
      :show-progress="false"
      :auto-upload="false"
      @on-choose-complete="onFileChange"
      @on-remove="deleteFile"
    ></u-upload>

    <u-select
      @confirm="onPickerChange($event, currentSamplingIndex)"
      :default-value="[
        this.form.DealerSamplingSellList[currentSamplingIndex]
          ? this.form.DealerSamplingSellList[currentSamplingIndex].brandIndex
          : -1
      ]"
      v-model="showBrandPicker"
      :list="DataBaseInfo.CompetingGoodsBrandA_BaseList"
      label-name="Value"
      value-name="Key"
      safe-area-inset-bottom
    ></u-select>

    <u-select
      @confirm="onVisitSellPickerChange($event, currentVisitSellIndex)"
      :default-value="[
        form.DealerVisitSellList[currentVisitSellIndex]
          ? form.DealerVisitSellList[currentVisitSellIndex].brandIndex
          : -1
      ]"
      v-model="showVisitSellPicker"
      :list="DataBaseInfo.CompetingGoodsBrandA_BaseList"
      label-name="Value"
      value-name="Key"
      safe-area-inset-bottom
    ></u-select>

    <u-select
      @confirm="onProductPickerChange($event, currentSamplingIndex, 1)"
      :default-value="[0]"
      v-model="showProductPicker"
      :list="
        form.DealerSamplingSellList[currentSamplingIndex]
          ? form.DealerSamplingSellList[currentSamplingIndex].productList
          : []
      "
      label-name="Text"
      value-name="Id"
      safe-area-inset-bottom
    ></u-select>

    <u-select
      @confirm="onProductPickerChange($event, currentVisitSellIndex, 2)"
      :default-value="[0]"
      v-model="showVisitSellProductPicker"
      :list="
        form.DealerVisitSellList[currentVisitSellIndex]
          ? form.DealerVisitSellList[currentVisitSellIndex].productList
          : []
      "
      label-name="Text"
      value-name="Id"
      safe-area-inset-bottom
    ></u-select>
  </view>
</template>

<script>
export default {
  data() {
    return {
      btnDisabled: false,
      customStyle: {
        fontSize: '26rpx'
      },
      list: [
        {
          name: '基础信息'
        },
        {
          name: '产品信息'
        },
        {
          name: '销售信息'
        },
        {
          name: '门店周边情况'
        },
        // {
        // 	name: '门店展陈信息'
        // },
        {
          name: '门店开户照片'
        },
        {
          name: '渠道调整申请'
        }
      ],
      current: 0,

      currentIndex: 0,

      IsNewStore: 0,

      DealerId: null,
      Level: null,
      loadCity: false,

      currentSamplingIndex: 0,

      currentVisitSellIndex: 0,

      showProductPicker: false,
      showVisitSellProductPicker: false,
      productOptions: [],
      showVisitSellPicker: false,

      showBrandPicker: false,

      FirstDataBaseInfo: {
        BusinessCategory_BaseList: [],
        CompetingGoodsBrandA_BaseList: [],
        CompetingGoodsBrandB_BaseList: [],
        CompetingGoodsBrandC_BaseList: [],
        DealerApplyFor_BaseList: [],
        DealerGrade_BaseList: [],
        DealerMaterialRequirements_BaseList: [],
        DealerShutDown_BaseList: [],
        DealerType_BaseList: [],
        DealerAndGoReason_BaseList: []
      },
      DoubleDataBaseInfo: {
        BusinessCategory_BaseList: [],
        CompetingGoodsBrandA_BaseList: [],
        CompetingGoodsBrandB_BaseList: [],
        CompetingGoodsBrandC_BaseList: [],
        DealerApplyFor_BaseList: [],
        DealerGrade_BaseList: [],
        DealerMaterialRequirements_BaseList: [],
        DealerShutDown_BaseList: [],
        DealerType_BaseList: [],
        DealerAndGoReason_BaseList: []
      },

      Door_Dealer_BaseInfo: {},
      Double_Dealer_BaseInfo: {},
      First_Dealer_BaseInfo: {},

      DataBaseInfo: {},

      DealerGrade_VisitList: [],

      DealerVisitCategorylistModel: [],

      FirstDealerInfo: {
        Dealer_BaseInfo: {
          Account: '',
          Address: '',
          CityId: null,
          Created: null,
          DealerId: null,
          Delivery_Address: '',
          Delivery_CityId: null,
          Delivery_DistrictId: null,
          Delivery_ProvinceId: null,
          DistrictId: null,
          IsFictitious: null,
          KeDealerNo: '',
          Level: 1,
          LevelName: '',
          Mobile: '',
          Name: '',
          NickName: '',
          Parent_DealerId: null,
          Parent_Name: '',
          ProvinceId: 0,
          Referred: '',
          State: null,
          Telephone: ''
        },
        Dealer_OtherInfo: {
          BlessingNote: '',
          BossBirthday: null,
          BossName: '',
          BossPhone: '',
          BusinessCategory: '',
          BusinessLicenseA: '',
          CompetingGoodsBrandA: '',
          CompetingGoodsBrandB: '',
          CompetingGoodsBrandC: '',
          DealerGrade: null,
          DealerType: null,
          IsSign: null,
          IsVIP: null,
          LastYearsBDRSales: null,
          PeopleNum: null,
          PercentageBDRSales: null,
          TotalSales: null,
          TreatyPhoto: '',
          TreatyPhotoType: null
        },
        Dealer_RelationList: []
      },
      DoubleDealerInfo: {
        Dealer_BaseInfo: {
          Account: '',
          Address: '',
          CityId: null,
          Created: null,
          DealerId: null,
          Delivery_Address: '',
          Delivery_CityId: null,
          Delivery_DistrictId: null,
          Delivery_ProvinceId: null,
          DistrictId: null,
          IsFictitious: null,
          KeDealerNo: '',
          Level: 2,
          LevelName: '',
          Mobile: '',
          Name: '',
          NickName: '',
          Parent_DealerId: null,
          Parent_Name: '',
          ProvinceId: null,
          Referred: '',
          State: null,
          Telephone: ''
        },
        Dealer_OtherInfo: {
          BlessingNote: '',
          BossBirthday: '',
          BossName: '',
          BossPhone: '',
          BusinessCategory: '',
          BusinessLicenseA: '',
          CompetingGoodsBrandA: '',
          CompetingGoodsBrandB: '',
          CompetingGoodsBrandC: '',
          DealerGrade: '',
          DealerType: '',
          IsSign: '',
          IsVIP: '',
          LastYearsBDRSales: '',
          PeopleNum: '',
          PercentageBDRSales: '',
          TotalSales: '',
          TreatyPhoto: '',
          TreatyPhotoType: ''
        },
        Dealer_RelationList: []
      },

      ApplyForReasonId: '',
      Requirements: '',
      OtherNote: '',
      Remark: '',

      form: {
        DealerId: null,
        ApplyForType: 1,

        Double_Dealer_BaseInfo: {},
        Double_Dealer_OtherInfo: {},
        Doubel_ApplyForReasonId: null,
        Doubel_Requirements: '',
        Doubel_OtherNote: '',
        Doubel_Remark: '',

        Door_Dealer_BaseInfo: {},
        Door_Dealer_OtherInfo: {
          FlagshipState: '',
          Sampling: '',
          OldDoor: ''
        },
        Door_ApplyForReasonId: null,
        Door_Requirements: '',
        Door_OtherNote: '',
        Door_Remark: '',
        InitialStorePhoto: [],

        DealerVisitSellList: [],
        DealerVisitInfoModelList: [],
        DealerSamplingSellList: [],

        DealerPeopleNumList: [],

        Door_ApplyForReasonId: '',
        Door_Requirements: '',
        Door_OtherNote: '',
        Door_Remark: '',

        Doubel_ApplyForReasonId: '',
        Doubel_Requirements: '',
        Doubel_OtherNote: '',
        Doubel_Remark: '',
        Aub_Brand: ''
      }
    };
  },

  onLoad(options) {
    console.log(options);

    if (options.DealerId) {
      this.form.DealerId = options.DealerId;
    }

    if (options.Level) {
      this.Level = options.Level;
    }

    if (options.IsNewStore) {
      this.IsNewStore = 1;
    }

    console.log(options);

    this.init();

    this.getDealerVisitList();

    this.getDealerVisitSell();
  },

  computed: {
    count_A() {
      if (!this.DataBaseInfo.CompetingGoodsBrandA_BaseList) {
        return 0;
      }
      return this.DataBaseInfo.CompetingGoodsBrandA_BaseList.filter(item => item.checked).length;
    },
    count_B() {
      if (!this.DataBaseInfo.CompetingGoodsBrandB_BaseList) {
        return 0;
      }
      return this.DataBaseInfo.CompetingGoodsBrandB_BaseList.filter(item => item.Key != 80).filter(item => item.checked)
        .length;
    },
    count_C() {
      if (!this.DataBaseInfo.CompetingGoodsBrandC_BaseList) {
        return 0;
      }
      return this.DataBaseInfo.CompetingGoodsBrandC_BaseList.filter(item => item.Key != 81).filter(item => item.checked)
        .length;
    }
  },

  methods: {
    onBusinessCategoryChange(e) {
      this.form.Double_Dealer_OtherInfo.BusinessCategory = e.toString();
    },
    onCompetingGoodsBrandAChange(e) {
      this.form.Double_Dealer_OtherInfo.CompetingGoodsBrandA = e.toString();
    },
    onCompetingGoodsBrandBChange(e) {
      this.form.Double_Dealer_OtherInfo.CompetingGoodsBrandB = e.toString();
    },
    onCompetingGoodsBrandCChange(e) {
      this.form.Double_Dealer_OtherInfo.CompetingGoodsBrandC = e.toString();
    },
    onStoreBusinessCategoryChange(e) {
      this.form.Door_Dealer_OtherInfo.BusinessCategory = e.toString();
    },
    onStoreCompetingGoodsBrandAChange(e) {
      this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandA = e.toString();
    },
    onStoreCompetingGoodsBrandBChange(e) {
      this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandB = e.toString();
    },
    onStoreCompetingGoodsBrandCChange(e) {
      this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandC = e.toString();
    },

    onRequirementsChange(e) {
      this.form.Door_Requirements = e.toString();
    },

    onFileChange(list, name) {
      const file = list[list.length - 1].file;
      this.$fileUpload(file).then(res => {
        this.DealerVisitCategorylistModel[this.currentIndex].Pic = res.key;
      });
    },

    init() {
      this.$u.api
        .newDealerInit({
          DealerId: this.form.DealerId,
          Level: this.Level
        })
        .then(res => {
          const {
            ResultCode,
            ResultMessage,
            DataBaseInfo,
            First_Dealer_OtherInfo,
            First_Dealer_RelationList,
            Double_Dealer_OtherInfo,
            Double_Dealer_BaseInfo,
            Store_Location_List,
            InitialStorePhoto,
            First_Dealer_BaseInfo
          } = res;
          if (ResultCode === 1) {
            if (InitialStorePhoto) {
              this.form.InitialStorePhoto = InitialStorePhoto;
            }

            DataBaseInfo.StoreBusinessCategory_BaseList = JSON.parse(
              JSON.stringify(DataBaseInfo.BusinessCategory_BaseList)
            );

            DataBaseInfo.StoreCompetingGoodsBrandA_BaseList = JSON.parse(
              JSON.stringify(DataBaseInfo.CompetingGoodsBrandA_BaseList)
            );
            DataBaseInfo.StoreCompetingGoodsBrandB_BaseList = JSON.parse(
              JSON.stringify(DataBaseInfo.CompetingGoodsBrandB_BaseList)
            );
            DataBaseInfo.StoreCompetingGoodsBrandC_BaseList = JSON.parse(
              JSON.stringify(DataBaseInfo.CompetingGoodsBrandC_BaseList)
            );

            this.DataBaseInfo = DataBaseInfo;

            if (Double_Dealer_BaseInfo) {
              this.Double_Dealer_BaseInfo = Double_Dealer_BaseInfo;
            }

            if (First_Dealer_BaseInfo) {
              this.First_Dealer_BaseInfo = First_Dealer_BaseInfo;
            }

            this.DoubleDealerInfo.Dealer_BaseInfo = Double_Dealer_BaseInfo;
            this.DoubleDealerInfo.Dealer_OtherInfo = Double_Dealer_OtherInfo;

            this.$refs.basicForm.initForm({
              Dealer_BaseInfo: {},
              Dealer_OtherInfo: {},
              DealerAuditInfo: {},
              Store_Location_List: !Store_Location_List ? [] : Store_Location_List
            });

            this.loadCity = true;
          }
        });
    },

    getDealerVisitList() {
      this.$u.api
        .getDealerApplyVisitList({
          ChannelAdjustmentId: 0
        })
        .then(res => {
          const {
            DealerVisitCategorylistModel,
            DealerSamplingSellMoodeList,
            DealerGrade_VisitList,
            DealerVisitInfoModelList,
            CompetingGoodsBrandDoubleSupply,
            FlagshipState,
            SalesVolume,
            Sampling,
            TotalSalesVolume,
            VisitRemake,
            ProductOtherInfo,
            DoubleSupply,
            DoubleSupplyString,
            OtherBrand
          } = res;
          this.DealerGrade_VisitList = DealerGrade_VisitList;

          this.form.Door_Dealer_OtherInfo.FlagshipState = FlagshipState;
          this.form.Door_Dealer_OtherInfo.Sampling = Sampling;

          DealerVisitCategorylistModel &&
            DealerVisitCategorylistModel.forEach(item => {
              let imgInfo = DealerVisitInfoModelList.find(info => info.DealerVisitCategoryId == item.Id);
              item.Pic = '';
              item.checked = false;
              if (imgInfo) {
                item.Pic = imgInfo.Pic;
                item.checked = true;
              }
            });

          this.DealerVisitCategorylistModel = DealerVisitCategorylistModel;
          if (DealerSamplingSellMoodeList && DealerSamplingSellMoodeList.length > 0) {
            this.form.VisitRecordInfo.Sampling = 1;
            DealerSamplingSellMoodeList.forEach(item => (item.productName = item.ProductModel));
            this.form.VisitRecordInfo.DealerSamplingSellList = DealerSamplingSellMoodeList;
          }
        });
    },

    selectFile(index) {
      this.currentIndex = index;
      this.$refs.upload.selectFile();
    },

    removeSampling(index) {
      this.form.DealerSamplingSellList.splice(index, 1);
    },

    removeVisitSell(index) {
      this.form.DealerVisitSellList.splice(index, 1);
    },

    addSampling() {
      this.form.DealerSamplingSellList.push({
        BrandName: '',
        BrandId: '',
        ProductModel: '',
        productName: '',
        Number: '',
        brandIndex: -1,
        productIndex: -1,
        productList: []
      });
    },

    addVisitSell() {
      this.form.DealerVisitSellList.push({
        BrandName: '',
        BrandId: '',
        ProductId: '',
        productName: '',
        Number: '',
        brandIndex: -1,
        productIndex: -1,
        productList: []
      });
    },

    addPersonCount() {
      this.form.DealerPeopleNumList.push({
        Title: '',
        Num: ''
      });
    },

    removePersonCount(index) {
      this.form.DealerPeopleNumList.splice(index, 1);
    },

    onVisitSellPickerChange(e, visitSellIndex) {
      let brandId, name;
      if (e[0].label && e[0].value) {
        name = e[0].label;
        brandId = e[0].value;
        this.form.DealerVisitSellList[
          visitSellIndex
        ].brandIndex = this.DataBaseInfo.CompetingGoodsBrandA_BaseList.findIndex(item => item.Key == e[0].value);
        this.form.DealerVisitSellList[visitSellIndex].BrandName = name;
        this.form.DealerVisitSellList[visitSellIndex].BrandId = brandId;
      } else {
        name = this.DataBaseInfo.CompetingGoodsBrandA_BaseList[0].Value;
        brandId = this.DataBaseInfo.CompetingGoodsBrandA_BaseList[0].Key;
        this.form.DealerVisitSellList[visitSellIndex].brandIndex = 0;
        this.form.DealerVisitSellList[visitSellIndex].BrandName = name;
        this.form.DealerVisitSellList[visitSellIndex].BrandId = brandId;
      }
      this.getDoorVisitBrandProductList(brandId, visitSellIndex, 2);
    },

    async getDoorVisitBrandProductList(brandId, listIndex, type) {
      this.$u.api
        .getDoorVisitBrandProductList({
          BrandId: brandId
        })
        .then(res => {
          console.log(res);
          const { ResultCode, LogisticsList } = res;
          if (ResultCode == 0) {
            if (type == 1) {
              this.form.DealerSamplingSellList[listIndex].productList = LogisticsList;
            }
            if (type == 2) {
              this.form.DealerVisitSellList[listIndex].productList = LogisticsList;
            }
          }
        });
    },

    onProductPickerChange(e, listIndex, type) {
      let productId;
      if (e[0].label && e[0].value) {
        productId = e[0].value;
      } else {
        if (type == 1) {
          productId = this.form.DealerSamplingSellList[listIndex].productList[0].Id;
        }
        if (type == 2) {
          productId = this.form.DealerVisitSellList[listIndex].productList[0].Id;
        }
      }

      if (type == 1) {
        let productList = this.form.DealerSamplingSellList[listIndex].productList;
        let productIndex = productList.findIndex(item => item.Id == productId);
        if (productIndex > -1) {
          this.form.DealerSamplingSellList[listIndex].productIndex = productIndex;
          this.form.DealerSamplingSellList[listIndex].productName = productList[productIndex].Text;
          this.form.DealerSamplingSellList[listIndex].ProductModel = productList[productIndex].Text;
        }
      }

      if (type == 2) {
        let productList = this.form.DealerVisitSellList[listIndex].productList;
        let productIndex = productList.findIndex(item => item.Id == productId);
        if (productIndex > -1) {
          this.form.DealerVisitSellList[listIndex].productIndex = productIndex;
          this.form.DealerVisitSellList[listIndex].productName = productList[productIndex].Text;
          this.form.DealerVisitSellList[listIndex].ProductId = productList[productIndex].Id;
        }
      }
    },

    getDealerVisitSell() {
      this.$u.api
        .getDealerApplyVisitSell({
          ChannelAdjustmentId: 0
        })
        .then(res => {
          if (res.DealerVisit_Sell) {
            this.form.DealerVisitSellList = res.DealerVisit_Sell.map((item, index) => {
              let brand = this.DataBaseInfo.CompetingGoodsBrandA_BaseList.find(i => i.Key == item.Brand);

              return {
                BrandName: brand.Value,
                BrandId: item.Brand,
                ProductId: item.ProductId,
                ProductModel: item.ProductModel,
                productName: item.ProductModel,
                Number: item.Number,
                brandIndex: -1,
                productIndex: -1,
                productList: []
              };
            });
          }
        });
    },

    normalDealerSubmit() {
      let me = this;
      me.btnDisabled = true;
      let formParams = {};
      formParams = Object.assign(
        {},
        this.$refs.basicForm.form.Dealer_BaseInfo,
        this.$refs.basicForm.form.Dealer_OtherInfo
      );

      formParams.ApplyForReasonId = this.form.Door_ApplyForReasonId;
      formParams.Requirements = this.form.Door_Requirements;
      formParams.OtherNote = this.form.Door_OtherNote;
      formParams.Remark = this.form.Door_Remark;

      formParams.DealerId = this.form.DealerId;
      formParams.ApplyForType = 1;

      formParams.InitialStorePhoto = this.form.InitialStorePhoto;
      formParams.DealerSamplingSellList = this.form.DealerSamplingSellList;
      formParams.DealerPeopleNumList = this.form.DealerPeopleNumList;
      formParams.DealerVisitSellList = this.form.DealerVisitSellList;

      formParams.DealerType = this.form.Door_Dealer_OtherInfo.DealerType;
      formParams.BusinessCategory = this.form.Door_Dealer_OtherInfo.BusinessCategory;
      formParams.CompetingGoodsBrandA = this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandA;
      formParams.CompetingGoodsBrandB = this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandB;
      formParams.CompetingGoodsBrandC = this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandC;

      formParams.LY_DealerHeatingSales = this.form.Door_Dealer_OtherInfo.LY_DealerHeatingSales;
      formParams.LY_DealerAirConditionerSales = this.form.Door_Dealer_OtherInfo.LY_DealerAirConditionerSales;
      formParams.LY_DealerPurifiedWaterSales = this.form.Door_Dealer_OtherInfo.LY_DealerPurifiedWaterSales;
      formParams.LY_StoreHeatingSales = this.form.Door_Dealer_OtherInfo.LY_StoreHeatingSales;
      formParams.LY_StoreAirConditionerSales = this.form.Door_Dealer_OtherInfo.LY_StoreAirConditionerSales;
      formParams.LY_Store_BDR_PurifiedWaterSales = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales;
      formParams.LY_Store_BDR_HeatingSalesNum = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum;
      formParams.LY_Store_BDR_AirConditionerSalesNum = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum;
      formParams.LY_Store_BDR_PurifiedWaterSalesNum = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum;

      formParams.AS_HeatingMarketCapacity = this.form.Door_Dealer_OtherInfo.AS_HeatingMarketCapacity;
      formParams.AS_HeatPumpMarketCapacity = this.form.Door_Dealer_OtherInfo.AS_HeatPumpMarketCapacity;
      formParams.AS_CompetingStoresNum = this.form.Door_Dealer_OtherInfo.AS_CompetingStoresNum;
      formParams.AS_CompetingBrand = this.form.Door_Dealer_OtherInfo.AS_CompetingBrand;
      formParams.AS_BestCompetingBrand = this.form.Door_Dealer_OtherInfo.AS_BestCompetingBrand;
      formParams.AS_AnnualHeatingSalesCompetingProducts = this.form.Door_Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts;
      formParams.AS_CompetitiveAnnualHeatPumpSales = this.form.Door_Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales;
      formParams.AS_ReasonOpeningStore = this.form.Door_Dealer_OtherInfo.AS_ReasonOpeningStore;

      formParams.NY_Estimate_FireplaceNum = this.form.Door_Dealer_OtherInfo.NY_Estimate_FireplaceNum;
      formParams.NY_Estimate_CleanWaterNum = this.form.Door_Dealer_OtherInfo.NY_Estimate_CleanWaterNum;
      formParams.NY_Estimate_HeatPumpNum = this.form.Door_Dealer_OtherInfo.NY_Estimate_HeatPumpNum;

      formParams.SubsidyMethod = this.form.Door_Dealer_OtherInfo.SubsidyMethod;
      formParams.StoreApplyType = this.form.Door_Dealer_OtherInfo.StoreApplyType;

      formParams.FlagshipState = this.form.Door_Dealer_OtherInfo.FlagshipState;
      formParams.Sampling = this.form.Door_Dealer_OtherInfo.Sampling;
      formParams.OldDoor = this.form.Door_Dealer_OtherInfo.OldDoor;

      formParams.Aub_Brand = this.form.Aub_Brand;

      let SalesVolume = formParams.LastYearsBDRSales;
      let TotalSalesVolume = formParams.TotalSales;
      let percentOfSalesVolume = 0;

      formParams.PercentageBDRSales = ((SalesVolume / TotalSalesVolume) * 100).toFixed(2);

      formParams.DealerVisitInfoModelList = this.DealerVisitCategorylistModel.filter(item => item.checked).map(item => {
        return {
          Pic: item.Pic,
          DealerVisitCategoryId: item.Id
        };
      });

      let flag = formParams.InitialStorePhoto.slice(0, 3).every(item => !!item.PhotoUrl);

      if (!flag) {
        this.$u.toast('必须上传门头照片、近景图、远景图');
        return false;
      }

      this.$u.api.saveNormalDealer(formParams).then(res => {
        const { ResultCode, ResultMessage } = res;
        if (ResultCode === 1) {
          this.$u.toast(ResultMessage);
          setTimeout(() => {
            uni.navigateBack();
          }, 1000);
        } else {
          me.btnDisabled = false;
        }
      });
    },

    onSubmit() {
      if (this.IsNewStore) {
        this.newStoreSubmit();
      } else {
        this.normalDealerSubmit();
      }
    },

    newStoreSubmit() {
      let me = this;
      me.btnDisabled = true;
      const basicForm = this.$refs.basicForm;

      const dealerForm = this.$refs.basicForm2;

      if (this.Level == 1) {
        this.form.Double_Dealer_BaseInfo = { ...this.form.Double_Dealer_BaseInfo, ...dealerForm.form.Dealer_BaseInfo };
        this.form.Double_Dealer_OtherInfo = {
          ...this.form.Double_Dealer_OtherInfo,
          ...dealerForm.form.Dealer_OtherInfo
        };
      }

      this.form.Door_Dealer_BaseInfo = { ...this.form.Door_Dealer_BaseInfo, ...basicForm.form.Dealer_BaseInfo };

      basicForm.form.Dealer_OtherInfo.DealerType = this.form.Door_Dealer_OtherInfo.DealerType;
      basicForm.form.Dealer_OtherInfo.BusinessCategory = this.form.Door_Dealer_OtherInfo.BusinessCategory;
      basicForm.form.Dealer_OtherInfo.CompetingGoodsBrandA = this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandA;
      basicForm.form.Dealer_OtherInfo.CompetingGoodsBrandB = this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandB;
      basicForm.form.Dealer_OtherInfo.CompetingGoodsBrandC = this.form.Door_Dealer_OtherInfo.CompetingGoodsBrandC;

      basicForm.form.Dealer_OtherInfo.LY_DealerHeatingSales = this.form.Door_Dealer_OtherInfo.LY_DealerHeatingSales;
      basicForm.form.Dealer_OtherInfo.LY_DealerAirConditionerSales = this.form.Door_Dealer_OtherInfo.LY_DealerAirConditionerSales;
      basicForm.form.Dealer_OtherInfo.LY_DealerPurifiedWaterSales = this.form.Door_Dealer_OtherInfo.LY_DealerPurifiedWaterSales;
      basicForm.form.Dealer_OtherInfo.LY_StoreHeatingSales = this.form.Door_Dealer_OtherInfo.LY_StoreHeatingSales;
      basicForm.form.Dealer_OtherInfo.LY_StoreAirConditionerSales = this.form.Door_Dealer_OtherInfo.LY_StoreAirConditionerSales;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSales;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_HeatingSalesNum;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_AirConditionerSalesNum;
      basicForm.form.Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum = this.form.Door_Dealer_OtherInfo.LY_Store_BDR_PurifiedWaterSalesNum;

      basicForm.form.Dealer_OtherInfo.AS_HeatingMarketCapacity = this.form.Door_Dealer_OtherInfo.AS_HeatingMarketCapacity;
      basicForm.form.Dealer_OtherInfo.AS_HeatPumpMarketCapacity = this.form.Door_Dealer_OtherInfo.AS_HeatPumpMarketCapacity;
      basicForm.form.Dealer_OtherInfo.AS_CompetingStoresNum = this.form.Door_Dealer_OtherInfo.AS_CompetingStoresNum;
      basicForm.form.Dealer_OtherInfo.AS_CompetingBrand = this.form.Door_Dealer_OtherInfo.AS_CompetingBrand;
      basicForm.form.Dealer_OtherInfo.AS_BestCompetingBrand = this.form.Door_Dealer_OtherInfo.AS_BestCompetingBrand;
      basicForm.form.Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts = this.form.Door_Dealer_OtherInfo.AS_AnnualHeatingSalesCompetingProducts;
      basicForm.form.Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales = this.form.Door_Dealer_OtherInfo.AS_CompetitiveAnnualHeatPumpSales;
      basicForm.form.Dealer_OtherInfo.AS_ReasonOpeningStore = this.form.Door_Dealer_OtherInfo.AS_ReasonOpeningStore;

      basicForm.form.Dealer_OtherInfo.NY_Estimate_FireplaceNum = this.form.Door_Dealer_OtherInfo.NY_Estimate_FireplaceNum;
      basicForm.form.Dealer_OtherInfo.NY_Estimate_CleanWaterNum = this.form.Door_Dealer_OtherInfo.NY_Estimate_CleanWaterNum;
      basicForm.form.Dealer_OtherInfo.NY_Estimate_HeatPumpNum = this.form.Door_Dealer_OtherInfo.NY_Estimate_HeatPumpNum;

      basicForm.form.Dealer_OtherInfo.SubsidyMethod = this.form.Door_Dealer_OtherInfo.SubsidyMethod;
      basicForm.form.Dealer_OtherInfo.StoreApplyType = this.form.Door_Dealer_OtherInfo.StoreApplyType;

      basicForm.form.Dealer_OtherInfo.FlagshipState = this.form.Door_Dealer_OtherInfo.FlagshipState;
      basicForm.form.Dealer_OtherInfo.Sampling = this.form.Door_Dealer_OtherInfo.Sampling;
      basicForm.form.Dealer_OtherInfo.OldDoor = this.form.Door_Dealer_OtherInfo.OldDoor;

      this.form.Door_Dealer_OtherInfo = { ...this.form.Door_Dealer_OtherInfo, ...basicForm.form.Dealer_OtherInfo };

      if (this.Level == 1) {
        this.form.Doubel_ApplyForReasonId = dealerForm.form.ApplyForReasonId;
        this.form.Doubel_Requirements = dealerForm.form.Requirements;
        this.form.Doubel_OtherNote = dealerForm.form.OtherNote;
      }

      let SalesVolume = this.form.Door_Dealer_OtherInfo.LastYearsBDRSales;
      let TotalSalesVolume = this.form.Door_Dealer_OtherInfo.TotalSales;
      let percentOfSalesVolume = 0;

      if (!TotalSalesVolume) {
        percentOfSalesVolume = 0;
      }

      if (!SalesVolume) {
        percentOfSalesVolume = 0;
      }

      this.form.Door_Dealer_OtherInfo.PercentageBDRSales = ((SalesVolume / TotalSalesVolume) * 100).toFixed(2);

      this.form.DealerVisitInfoModelList = this.DealerVisitCategorylistModel.filter(item => item.checked).map(item => {
        return {
          Pic: item.Pic,
          DealerVisitCategoryId: item.Id
        };
      });

      let flag = this.form.InitialStorePhoto.slice(0, 3).every(item => !!item.PhotoUrl);
      if (!flag) {
        this.$u.toast('必须上传门头照片、近景图、远景图');
        return false;
      }

      this.$u.api.postNewDoorInsert(this.form).then(res => {
        const { ResultCode, ResultMessage } = res;
        if (ResultCode === 1) {
          this.$u.toast(ResultMessage);
          setTimeout(() => {
            uni.navigateBack();
          }, 1000);
        } else {
          me.btnDisabled = false;
        }
      });
    },

    change(index) {
      this.current = index;
    },
    confirm(e) {
      console.log(e);
    }
  }
};
</script>

<style lang="scss" scoped>
.radio-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(160rpx, 1fr));
  grid-template-rows: repeat(auto-fill, 60rpx);
  grid-auto-rows: 60rpx;
}

.radio-grid-3 {
  display: grid;
  grid-template-columns: repeat(2, minmax(160rpx, 1fr));
  grid-template-rows: repeat(auto-fill, 60rpx);
  grid-auto-rows: 60rpx;
}

.radio-grid-4 {
  display: grid;
  grid-template-columns: repeat(2, minmax(160rpx, 1fr));
  grid-template-rows: repeat(auto-fill, 60rpx);
  grid-auto-rows: 60rpx;
}

.unit {
  font-size: 22rpx;
  font-family: NotoSansHans;
  font-weight: 400;
  color: #2e2f32;
  line-height: 14rpx;
  margin-left: 30rpx;
}

.desc {
  font-size: 18rpx;
  font-family: NotoSansHans;
  font-weight: 400;
  color: #a7a9b1;
  line-height: 26rpx;
}

.btn-group {
  z-index: 10;
  background-color: #ffffff;
  position: fixed;
  bottom: 0;
  display: flex;
  left: 0;
  right: 0;
  padding: 60rpx 0;
}

.visit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 240rpx;
  gap: 20rpx 20rpx;
  padding: 20rpx;

  .visit-item {
    display: flex;
    flex-direction: column;
    text-align: left;

    .title {
      width: 200rpx;
    }
  }
}

.samling-item {
  background-color: #ffffff;
  padding: 0 20rpx;
}
</style>
